package com.shensi.appCollect.rocketmq;

import com.alibaba.fastjson.JSON;
import com.shensi.appCollect.pojo.SaasOrderBo;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;



@Component
@Slf4j
//@RocketMQMessageListener(topic = "CLEAR_ORDER", consumerGroup = "NONE_SAAS")
public class OrderConsumer implements RocketMQListener<String> {



    @Override
    public void onMessage(String message) {
        log.info("接收到的消息: {}", message);

        // 将 JSON 字符串转换为对象
        SaasOrderBo saasOrderBo = JSON.parseObject(message, SaasOrderBo.class);

        // 在这里处理接收到的消息，例如保存到数据库或执行其他业务逻辑
        // 示例：保存到数据库
        saveToDatabase(saasOrderBo);

        // 示例：执行其他业务逻辑
        // processBusinessLogic(saasOrderBo);
    }

    private void saveToDatabase(SaasOrderBo saasOrderBo) {
        // 实现保存到数据库的逻辑
        log.info("保存消息到数据库: {}", saasOrderBo);
    }

    private void processBusinessLogic(SaasOrderBo saasOrderBo) {
        // 实现其他业务逻辑的处理
        log.info("执行其他业务逻辑: {}", saasOrderBo);
    }
}
